/*
Copyright (C) 2009  Raymond Jeon
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/


#include "gl_smmp_func.h"
#include "gl_smmp_funcspam.h"
#include "gl_smmp_response.h"
#include "gl_mail_config.h"
#include "gl_mail_log.h"








////////////////////////////////////////////////////////////////////////////////
//	Date : 2003-3-26
//	Update : 
//	Author : Raymond Jeon
//	Parameters
//	Return Value  
//	Remarks 
////////////////////////////////////////////////////////////////////////////////

void GlSmmpFuncSpamTreatement(glsmmpsession_ *gsn, char *szName, char *szVal, int iMode, gllink_ **ll)
{
	int iRet = 0;
	
	if (gsn->iStat == SMMP_ADMIN)
	{
		switch (iMode)
		{
		case SPAMTREAT_ADD	:
			iRet = GlConfigAddBlockLinkList(szName, szVal, NULL, ll);
			break;
		case SPAMTREAT_DEL	:
			iRet = GlConfigDelBlockLinkList(szName, szVal, NULL, ll);
			break;
		case SPAMTREAT_VIEW	:
			GlConfigViewBlockData(gsn, szName, NULL, NULL);
			return;
		}
	}
	else
	{
		switch (iMode)
		{
		case SPAMTREAT_ADD	:
			iRet = GlUserConfigAddBlockData(gsn->szDir, szName, szVal, NULL);
			break;
		case SPAMTREAT_DEL	:
			iRet = GlUserConfigDelBlockData(gsn->szDir, szName, szVal, NULL);
			break;
		case SPAMTREAT_VIEW	:
			GlUserConfigViewBlockData(gsn, gsn->szDir, szName, NULL, NULL);
			return;
		}
	}

	glSmmpFuncError(gsn, iRet);
}







void GlSmmpFuncAddSpamFrom(glsmmpsession_ *gsn, char *szVal)
{
	GlSmmpFuncSpamTreatement(gsn, "SpamFrom", szVal, SPAMTREAT_ADD, &(glData.llSpamFrom));
}

void GlSmmpFuncAddSpamTo(glsmmpsession_ *gsn, char *szVal)
{
	GlSmmpFuncSpamTreatement(gsn, "SpamTo", szVal, SPAMTREAT_ADD, &(glData.llSpamTo));
}

void GlSmmpFuncAddSpamCc(glsmmpsession_ *gsn, char *szVal)
{
	GlSmmpFuncSpamTreatement(gsn, "SpamCc", szVal, SPAMTREAT_ADD, &(glData.llSpamCc));
}

void GlSmmpFuncAddSpamSubject(glsmmpsession_ *gsn, char *szVal)
{
	GlSmmpFuncSpamTreatement(gsn, "SpamSubject", szVal, SPAMTREAT_ADD, &(glData.llSpamSubject));
}

void GlSmmpFuncDelSpamFrom(glsmmpsession_ *gsn, char *szVal)
{
	GlSmmpFuncSpamTreatement(gsn, "SpamFrom", szVal, SPAMTREAT_DEL, &(glData.llSpamFrom));
}

void GlSmmpFuncDelSpamTo(glsmmpsession_ *gsn, char *szVal)
{
	GlSmmpFuncSpamTreatement(gsn, "SpamTo", szVal, SPAMTREAT_DEL, &(glData.llSpamTo));
}

void GlSmmpFuncDelSpamCc(glsmmpsession_ *gsn, char *szVal)
{
	GlSmmpFuncSpamTreatement(gsn, "SpamCc", szVal, SPAMTREAT_DEL, &(glData.llSpamCc));
}

void GlSmmpFuncDelSpamSubject(glsmmpsession_ *gsn, char *szVal)
{
	GlSmmpFuncSpamTreatement(gsn, "SpamSubject", szVal, SPAMTREAT_DEL, &(glData.llSpamSubject));
}

void GlSmmpFuncViewSpamFrom(glsmmpsession_ *gsn, char *szVal)
{
	GlSmmpFuncSpamTreatement(gsn, "SpamFrom", szVal, SPAMTREAT_VIEW, &(glData.llSpamFrom));
}

void GlSmmpFuncViewSpamTo(glsmmpsession_ *gsn, char *szVal)
{
	GlSmmpFuncSpamTreatement(gsn, "SpamTo", szVal, SPAMTREAT_VIEW, &(glData.llSpamTo));
}

void GlSmmpFuncViewSpamCc(glsmmpsession_ *gsn, char *szVal)
{
	GlSmmpFuncSpamTreatement(gsn, "SpamCc", szVal, SPAMTREAT_VIEW, &(glData.llSpamCc));
}

void GlSmmpFuncViewSpamSubject(glsmmpsession_ *gsn, char *szVal)
{
	GlSmmpFuncSpamTreatement(gsn, "SpamSubject", szVal, SPAMTREAT_VIEW, &(glData.llSpamSubject));
}


